/**
 * Author: NingpingGou
 * Date: 2012-11-15
 * Description: 
 */
package cn.gnp.framework.core.util;

import java.io.File;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 * @author NingpingGou
 *
 */
public class XMLUtil {
	public static Document parseXML(String fileName)
	{
		Document doc = null;
		try {
			File f = new File(fileName);
			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
			DocumentBuilder builder = factory.newDocumentBuilder();
			doc = builder.parse(f);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return doc;
	}
	
	public static NodeList getXMLNode(Document doc, String tagName)
	{
		NodeList nl = null;
		try {
			nl = doc.getElementsByTagName(tagName);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return nl;
	}	

}
